root = File.expand_path('../../', __FILE__)
lib = File.join(root, 'lib')
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

task :setup_key_map do
  require 'vigilem/evdev/system/keymap_loaders'
  require 'fileutils'
  
  sudo_cmd = if not `which rvmsudo`.empty?
    'rvmsudo' 
  else
    `which sudo`.chomp
  end
  user = `whoami`
  puts `#{sudo_cmd} ruby ./rake_helper.rb #{user}`
end

task :x11_context_filter do
  require 'vigilem/x11/stat'
  vxd = Vigilem::X11::Stat.default
  if vxd.available?
    vxd.install
  end
end

task :init_steps do
  Rake::Task["setup_key_map"].invoke
  Rake::Task["x11_context_filter"].invoke
end

task default: :init_steps
